package com.laan.plat;

import android.content.res.Resources;


public class EnemyAI extends Pawn {
	
	public static int ENEMYWIDTH = 48;
	public static int ENEMYHEIGHT = 22*2;
	
	public static float ENEMYJUMPSPEED = 5f;
	public static float ENEMYMOVSPEED = 5f;
	public float distx = 0;
	public static float MAXDIST = 3*Plats.PLATWIDTH;
	public boolean movinRight = true;
	
	public EnemyAI(int idIdle, int idWalk, Resources res, float startx, float starty) {
		super(idIdle, idWalk, res, startx, starty, ENEMYWIDTH, ENEMYHEIGHT);
	}
	
	public void init() {
		super.init();
		jumpspeed = ENEMYJUMPSPEED;
		movspeed = ENEMYMOVSPEED;
	}

	@Override
	public void actualitza() {
		super.actualitza();
		if(isDead) return;
		
		distx += Math.abs(lastvx);
//		if(GV.Game.prota.rec.left < rec.left) {
		if(distx > MAXDIST) {
			movinRight = !movinRight;
			distx = 0;
		}
		if(movinRight) moveRight();
		else moveLeft();
		if(distx == MAXDIST/2) jump();
	}

}
